function DialogManager() {
    var template = "dialogTemplate"; 
    var dialogTemplate = "dialogContentTemplate";
	var dialogs = new Object();
	var divs = new Object();
	var dialogContent = new Object();
	var divNames = new Array();
	var escape="_dialog_";

    this.loadAll = true;
	this.update = function updateManager(peer, dialog, i){
		if (divs[peer] == null && dialogs[peer]==null){
			divs[peer] = document.createElement("div");
		    document.getElementsByTagName("body")[0].appendChild( divs[peer]);
		    divs[peer].id = escape+peer;
		    divNames.push(divs[peer].id);
			dialogs[peer] = new Array();
			divs[peer].style.width = "205px";
			divs[peer].style.height = "250px";
			divs[peer].style.border = "1px solid";		
			divs[peer].style.zIndex = 10+i*2;
			divs[peer].style.position = "absolute";
			var left = i*200+400;
			divs[peer].style.left = left+"px";
			divs[peer].style.top = "60px";
			divs[peer].style.display = "block";
			var data = new Object();
			data["peer"] = peer;
			divs[peer].innerHTML =  TrimPath.processDOMTemplate(template, data);		  
			loadAll = false;
			dialogContent[peer] = document.createElement("div");
			divs[peer].appendChild(dialogContent[peer]);
			dialogContent[peer].style.position="absolute";
			dialogContent[peer].style.top="20px"; 
			dialogContent[peer].style.left="0px"; 
			dialogContent[peer].style.width="204px"; 
			dialogContent[peer].style.height="200px"; 
			dialogContent[peer].style.border="1px solid"; 
			dialogContent[peer].style.overflow="scroll";
			dialogContent[peer].style.backgroundColor="#EEEEEE";
			ADD_DHTML(divs[peer].id);
		}
		var dialogObj = new Object();
		dialogObj.dialogs= dialog;
		dialogContent[peer].innerHTML = TrimPath.processDOMTemplate(dialogTemplate, dialogObj);		  
	}
	
	this.diagDivNames = function(){
		return divNames;
	}
	
}


